﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FillCartridgeBBB.Models
{
    public class DataManager
    {
        private FillCartridgeDbEntities _db;

        public DataManager(string connectionString)
        {
            _db = new FillCartridgeDbEntities(connectionString);
        }

        private CustomerRepository customers;
        private PrinterRepository printers;
        private CartridgeRepository cartridges;
        private StatesRepository states;
        private DepartmentRepository departments;
        private FillRepository fills;
        private MovementRepository movement;

        public CustomerRepository Customers
        {
            get { return customers ?? (customers = new CustomerRepository(_db)); }
        }

        public PrinterRepository Printers
        {
            get { return printers ?? (printers = new PrinterRepository(_db)); }
        }

        public CartridgeRepository Cartridges
        {
            get { return cartridges ?? (cartridges = new CartridgeRepository(_db)); }
        }

        public StatesRepository States
        {
            get { return states ?? (states = new StatesRepository(_db)); }
        }
        
        public DepartmentRepository Departmets
        {
            get { return departments ?? (departments = new DepartmentRepository(_db)); }
        }
    
        public FillRepository Fills
        {
            get { return fills ?? (fills = new FillRepository(_db)); }
        }

        public MovementRepository Movement
        {
            get { return movement ?? (movement = new MovementRepository(_db)); }
        }
    }
}
